package com.ktjy;

import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class EmployeeTest extends Employee{
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException, NoSuchFieldException {
        Class clz = Class.forName("com.ktjy.Employee");
        Constructor constructor = clz.getDeclaredConstructor();

        Object object = constructor.newInstance();

        Field empNo = clz.getDeclaredField("empNo");
        Field empName = clz.getDeclaredField("empName");
        Field empPost = clz.getDeclaredField("empPost");
        Field empSalary = clz.getDeclaredField("empSalary");

        empNo.setAccessible(true);
        empNo.set(object,"12");
        empName.setAccessible(true);
        empName.set(object,"1234");
        empPost.setAccessible(true);
        empPost.set(object,"1234");
        empSalary.setAccessible(true);
        empSalary.set(object,10000);

        Method method = clz.getDeclaredMethod("showInfo");

        method.invoke(object);

    }
}
